<HTML>
<TITLE>JDComPort VBScript Sample</TITLE>
<HEAD>
<HTA:APPLICATION APPLICATIONNAME="myApp">
<!-- METADATA TYPE="typelib" FILE="C:\Windows\System32\scrrun.dll" -->
<meta http-equiv="X-UA-Compatible" content="IE=8" />


	
<SCRIPT LANGUAGE="VBScript">
 
  Sub SetSate
    Call JDComPort1.SetSate
    Call CreateFolderDemo
  end sub
	
  Sub SetupPorts
    call JDComPort1.SetupPorts
  end sub

  Sub FindJDdevices_	
        dim strdev
 	strdev=JDComPort1.FindJDdevices
        Document.forms.mbox.value = Document.forms.mbox.value  & "查找端口返回："  & strdev & chr(10)
 
  end sub
  Sub Open
     call JDComPort1.Open
  end sub
	
  Sub Close  
     call JDComPort1.Close
  end sub

  Sub ClearmBox
    Document.forms.mbox.value=""
  end sub
  dim  vartxt
    vartxt=" gz kosen co.td" 


  Sub DialupChanl6
	Call JDComPort1.SetHandUp(1,0)
	call giveTop
  End sub

  Sub DialupChanl7
	Call JDComPort1.SetHandUp(0,0)
	call giveTop
  End sub

  Sub DialupChanl61
	Call JDComPort1.SetHandUp(1,1)
	call giveTop
  End sub

  Sub DialupChanl71
	Call JDComPort1.SetHandUp(0,1)
	call giveTop
  End sub

  Sub DialupChanl62
	Call JDComPort1.SetHandUp(1,2)
	call giveTop
  End sub

  Sub DialupChanl72
	Call JDComPort1.SetHandUp(0,2)
	call giveTop
  End sub

  Sub DialupChanl612
	Call JDComPort1.SetHandUp(1,3)
	call giveTop
  End sub

  Sub DialupChanl712
	Call JDComPort1.SetHandUp(0,3)
	call giveTop
  End sub


  Sub GetLineStatus
        dim strLineStatus
	strLineStatus=JDComPort1.LineStatus(0)	
        Document.forms.mbox.value = Document.forms.mbox.value  & "线路1状态："  & strLineStatus & chr(10)
	call giveTop
  End sub



  Sub DialupChanl
	Call JDComPort1.DialupChanl("13822245761",0)
        call giveTop
  End sub

  Sub DialupChanl2
	Call JDComPort1.DialupChanl("95338",1)
	call giveTop
  End sub

  Sub DialupChanl3
	Call JDComPort1.DialupChanl("10086",2)
	call giveTop
  End sub

  Sub DialupChanl4
	Call JDComPort1.DialupChanl("13822245761",3)
	call giveTop
  End sub

  Sub DialupChanl78
	Call JDComPort1.DialupChanl("#808",0)
        call giveTop
  End sub

  Sub DialupChanl79
	Call JDComPort1.DialupChanl("#812",1)
	call giveTop
  End sub

  Sub DialupChanl80
	Call JDComPort1.DialupChanl("#812",2)
	call giveTop
  End sub

  Sub DialupChanl85
	Call JDComPort1.DialupChanl("#807",3)
	call giveTop
  End sub



  Sub PlayWaveFile1
  	Call JDComPort1.PlayWaveFile("D:\temp\Wavetest.wav",0)
  End  sub

  Sub PlayWaveFile2
  	Call JDComPort1.PlayWaveFile("D:\temp\Wavetest.wav",1)
  End  sub


  Sub PlayWaveabort_
  	Call JDComPort1.PlayWaveabort(0)
  End  sub

  Sub PlayWaveabort_2
  	Call JDComPort1.PlayWaveabort(1)
  End  sub


  Sub ReadFactryID_
	Dim strFactryID
  	strFactryID=JDComPort1.ReadFactryID()
	Document.forms.mbox.value =  Document.forms.mbox.value & strFactryID & chr(10)
	call giveTop
  End  sub

  Sub Get_FactoryID
    Document.forms.mbox.value = Document.forms.mbox.value & "FactoryID="  &  JDComPort1.ReadFactryID() & chr(10) 
    call giveTop
  end sub


  Sub ReadDevVer_
    Dim strDevVer 
    strDevVer=JDComPort1.ReadDevVer
    Document.forms.mbox.value = Document.forms.mbox.value & "设备型号和版本："  & strDevVer  & chr(10)
   call giveTop
  end sub


 sub StartWaveIn_
	call JDComPort1.startWaveIn(0,"d:\tele0\comeinhehe.wav")
 end sub 

 sub StopWaveIn_
	call JDComPort1.stopWaveIn(0)
 end sub 

Sub   CreateFolderDemo() 
    Dim   fso, f ,str
     fso   =   CreateObject( "Scripting.FileSystemObject") 
     str=JDComPort1.WavePath
    if   fso.folderexists( str)   then 
      str= "文件夹已经存在! " 
    else 
      f   =   fso.CreateFolder(str) 
      str =f.Path 
    end   if 
    
    Document.forms.mbox.value = Document.forms.mbox.value  & str & chr(10)

 End sub


</SCRIPT>
	
<SCRIPT LANGUAGE="VBScript">

  Sub JDComPort1_OnKeyPress(key, devid)
    Document.forms.str3.value = devid & ":" & key
    Document.forms.mbox.value = Document.forms.mbox.value & Document.forms.str3.value & chr(10)
    call giveTop
  end sub

  Sub JDComPort1_OnRead(s,t,devid,wavefile)
    if devid="D"  then
	devid="拨出D"
    end if
    Document.forms.textfieldk.value = devid & ":" & s
    Document.forms.str4.value =  devid & ":" & s
    Document.forms.mbox.value = Document.forms.mbox.value & Document.forms.textfieldk.value & chr(10) 
    if wavefile<>"" then
	<!--Document.forms.mbox.value = Document.forms.mbox.value & "OnRead录音发生，生成录音文件："&chr(10) &devid &"  " & wavefile & chr(10)-->
    end if
    call giveTop
 end sub

  sub JDComPort1_OnClose()
	Document.forms.mbox.value = Document.forms.mbox.value &"设备关闭"&chr(10)
        call giveTop	
  end sub

  sub JDComPort1_OnOpen()
      Dim strDevVer 
      strDevVer=JDComPort1.ReadDevVer
      Document.forms.mbox.value = Document.forms.mbox.value &"设备打开"&chr(10)& "设备型号和版本："  & strDevVer & chr(10)
      call giveTop
  end sub


  Sub  JDComPort1_OnStartRecord(devid, FileName)
    if FileName<>"" then
	Document.forms.mbox.value = Document.forms.mbox.value & chr(10)& "录音事件OnStartRecord发生生成录音文件：" &chr(10) &devid &":  "& JDComPort1.WavePath & FileName             & chr(10)
    end if	
    call giveTop
  end sub

  Sub  JDComPort1_OnEndRecord(devid, FileName)
    if FileName<>"" then
	Document.forms.mbox.value = Document.forms.mbox.value & "录音事件OnEndRecord录音文件结束："  &chr(10) &devid &":  " &JDComPort1.WavePath & FileName &chr(10)
    end if	
	call giveTop
  end sub

 



</SCRIPT>

<SCRIPT>
  sub giveTop()
    Document.forms.mbox.scrollTop=Document.forms.mbox.scrollHeight 
  end sub
</SCRIPT>
	
</HEAD>


<BODY onload="SetupPorts;Open;">
<center>

<OBJECT ID="JDComPort1" WIDTH=36 HEIGHT=36
 CLASSID="CLSID:C4751F74-C039-4272-8532-11F7ACBAD184">
    <PARAM NAME="_ExtentX" VALUE="953">
    <PARAM NAME="_ExtentY" VALUE="953">
</OBJECT>

    <FORM ACTION="#" NAME="forms"><table width="100%" border="1" cellpadding="0" cellspacing="0" onload height="330">
      <tr> 
        <td width="9%" height="30"><center><h3>JDComPort.OCX 控件来电实例 </h3></center></td>
      </tr>
      <tr> 
        <td width="9%" height="30"><center>
        来电
        <INPUT TYPE=text SIZE=52 NAME="textfieldk" >
        按键
        <INPUT TYPE=text SIZE=10 NAME="str3">
        按键4
        <INPUT TYPE=text SIZE=10 NAME="str4">

        </center></td>
      </tr>
      <tr> 
        <td width="9%" height="30"><center>
         消息窗口<br>
        <textarea id=allshowFromJD  name="mbox" cols="100" rows="30">
        </textarea>
        </center></td>
      </tr>
      <tr>
        <td width="9%" height="30"><center>
        <INPUT TYPE=button VALUE="系统设置" ONCLICK="SetSate" NAME="Button1">
        <INPUT TYPE=button VALUE="查找设备" ONCLICK="SetupPorts" NAME="Button4">
        <INPUT TYPE=button VALUE="后台形式查找设备" ONCLICK="FindJDdevices_" NAME="Button9">
        <INPUT TYPE=button VALUE="打开设备" ONCLICK="Open" NAME="DialChar">
        <INPUT TYPE=button VALUE="关闭设备" ONCLICK="Close" NAME="Button11">
        <INPUT TYPE=button VALUE="清除显示" ONCLICK="ClearmBox" NAME="DialChar">
        </center></td>
      </tr>
      <tr>
        <td width="9%" height="30"><center>
        <INPUT TYPE=button VALUE="读厂商ID" ONCLICK="ReadFactryID_" NAME="Button8">
        <INPUT TYPE=button VALUE="读设备型号" ONCLICK="ReadDevVer_" NAME="Button11">
        <INPUT TYPE=button VALUE="设摘机1" ONCLICK="DialupChanl6" NAME="Button6">
        <INPUT TYPE=button VALUE="设挂机1" ONCLICK="DialupChanl7" NAME="Button7">

        <INPUT TYPE=button VALUE="设摘机2" ONCLICK="DialupChanl61" NAME="Button61">
        <INPUT TYPE=button VALUE="设挂机2" ONCLICK="DialupChanl71" NAME="Button71">

        <INPUT TYPE=button VALUE="设摘机3" ONCLICK="DialupChanl62" NAME="Button62">
        <INPUT TYPE=button VALUE="设挂机3" ONCLICK="DialupChanl72" NAME="Button72">

        <INPUT TYPE=button VALUE="设摘机4" ONCLICK="DialupChanl612" NAME="Button612">
        <INPUT TYPE=button VALUE="设挂机4" ONCLICK="DialupChanl712" NAME="Button712">

        <INPUT TYPE=button VALUE="电话线状态" ONCLICK="GetLineStatus" NAME="Button15">

        <INPUT TYPE=button VALUE="回拨#809" ONCLICK="DialupChanl" NAME="Button2">
	<INPUT TYPE=button VALUE="回拨#810" ONCLICK="DialupChanl2" NAME="Button3">
	<INPUT TYPE=button VALUE="回拨#809" ONCLICK="DialupChanl3" NAME="Button4">
	<INPUT TYPE=button VALUE="回拨10000号" ONCLICK="DialupChanl4" NAME="Button5">
        </center></td>
      </tr>
      <tr>
        <td width="9%" height="30"><center>
        <INPUT TYPE=button VALUE="chn1回拨#808" ONCLICK="DialupChanl78" NAME="Button78">
	<INPUT TYPE=button VALUE="chn2回拨#807" ONCLICK="DialupChanl79" NAME="Button79">
	<INPUT TYPE=button VALUE="chn3回拨#812" ONCLICK="DialupChanl80" NAME="Button80">
	<INPUT TYPE=button VALUE="chn4回拨#807" ONCLICK="DialupChanl85" NAME="Button85">
	</td>
      </tr>	
      <tr>
        <td width="9%" height="30"><center>
        <INPUT TYPE=button VALUE="开始录音" ONCLICK="StartWaveIn_" NAME="Button12">
        <INPUT TYPE=button VALUE="结束录音" ONCLICK="StopWaveIn_" NAME="Button13">
        <INPUT TYPE=button VALUE="回放线路1" ONCLICK="PlayWaveFile1" NAME="Button6">
        <INPUT TYPE=button VALUE="停止回放1" ONCLICK="PlayWaveabort_" NAME="Button10">
        <INPUT TYPE=button VALUE="回放线路2" ONCLICK="PlayWaveFile2" NAME="Button19">
        <INPUT TYPE=button VALUE="停止回放2" ONCLICK="PlayWaveabort_2" NAME="Button20">

        </center></td>
      </tr>
    </table>
    </FORM></center>
</BODY>
</HTML>